﻿@using Microsoft.FluentUI.AspNetCore.Components
@using eShopSupport.ServiceDefaults.Clients.Backend

@if (Ticket is null)
{
    <div class="loading-progress">
        <FluentProgress />
    </div>
}
else
{
    <div class="messages">
        @if (!string.IsNullOrEmpty(Ticket?.LongSummary))
        {
            <div class="summary">
                <div class="summary-text">
                    <div>💡</div>
                    <div>
                        <strong>Summary:</strong>
                        @Ticket.LongSummary
                    </div>
                </div>
            </div>
        }

        @foreach (var message in Ticket!.Messages)
        {
            <div class="message @(message.IsCustomerMessage ? "customer" : "support")">
                <div class="message-metadata">
                    <span class="timestamp">@message.CreatedAt.ToShortDateString()</span>
                    <span class="filler">by</span>
                    <span class="sender">@(message.IsCustomerMessage ? Ticket.CustomerFullName : "Support")</span>
                </div>
                <div class="message-text">@message.MessageText</div>
            </div>
        }
    </div>
}

@code {
    [Parameter]
    public TicketDetailsResult? Ticket { get; set; }
}
